package booking.utils;

import org.junit.Assert;
import org.openqa.selenium.WebElement;

public class Verificator{
	
	public Verificator assertFail(String reason)
    {
        Assert.assertTrue(reason, false);
        return this;
    }
	
	public Verificator checkIfElementDisplayedValueIs(String actualValue, String expectedValue)
    {
        Assert.assertTrue("The element's display value is '" + actualValue + "' but '" + expectedValue
                + "' was expected", actualValue.equals(expectedValue));
        return this;
    }

    public Verificator checkIfElementDisplayedValueLike(String actualValue, String expectedValue)
    {
        Assert.assertTrue("The element's display value is '" + actualValue + "' but '" + expectedValue
                + "' was expected", actualValue.contains(expectedValue));
        return this;
    }

    public Verificator checkElementAttributeValueIs(WebElement element, String attribute, String expectedValue)
    {
        String actualValue = element.getAttribute(attribute);
        Assert.assertTrue("The element's '" + attribute + "' attribute's value is '" + actualValue + "' but '"
                + expectedValue + "' was expected", actualValue.equals(expectedValue));
        return this;
    }

    public Verificator checkElementAttributeValueLike(WebElement element, String attribute, String expectedValue)
    {
    	String actualValue = element.getAttribute(attribute);
        Assert.assertTrue("The element's '" + attribute + "' attribute's value is '" + actualValue + "' but '"
                + expectedValue + "' was expected", actualValue.contains(expectedValue));
        return this;
    }

    public Verificator checkElementIsSelected(WebElement element)
    {
        Assert.assertTrue("The element was expected to be selected but it wasn't", element.isSelected());
        return this;
    }

    public Verificator checkElementIsNotSelected(WebElement element)
    {
        Assert.assertFalse("The element wasn't expected to be selected", element.isSelected());
        return this;
    }

    public Verificator checkElementIsVisible(WebElement element)
    {
        Assert.assertTrue("The element was expected to be visible", element.isDisplayed());
        return this;
    }

}
